package adv46.chat;

import java.io.*;
import java.net.Socket;
import java.util.Scanner;

/**
 * @author oldliu
 * @since 1.0
 */
public class ChatClient {
    public static void main(String[] args) {
        //localhost这个代表本机
        //127.0.0.1也代表本机
        try {
            Socket s=new Socket("127.0.0.1",8888);
            BufferedReader br=new BufferedReader(new InputStreamReader(s.getInputStream()));
            PrintWriter pw=new PrintWriter(s.getOutputStream(),true);
            Scanner in=new Scanner(System.in);
            while (true){
                System.out.print("唠嗑：");
                String input=in.next();
                pw.println(input);
                //pw.flush();
                String reply=br.readLine();
                System.out.println("服务器回复："+reply);
                if("quit".equals(input))
                    break;
            }
            s.close();

        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
